using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CreateEffects : MonoBehaviour
{
    // [Header("effects的父级")]

    public bool is_hit_target = true;
    
    public Transform left_effects_parent_trans;
    public Transform right_effects_parent_trans;

    public GameObject left_effect_prefab;
    public GameObject right_effect_prefab;

    public void btn_create_effects(int is_left)
    {
        if (!is_hit_target)
            return;
        
        var effects_parent_trans =
            BdPackage.BdUtils.conv_to_bool(is_left) ? left_effects_parent_trans : right_effects_parent_trans;
        
        var effect_prefab = BdPackage.BdUtils.conv_to_bool(is_left) ? left_effect_prefab : right_effect_prefab;
        // var effects_parent_trans = effect_prefab.transform.parent;

        string effect_obj_name = $"{effect_prefab.name}__obj";
        // if (BdPackage.BdUtils.is_null(effect_obj_name))
        //     effect_obj_name = "effect";
        // var new_obj = ObjectPool.instance.GetObj(effect_obj_name, prefab_path: "Prefabs/effects");
        var new_obj = ObjectPool.instance.GetObj(effect_obj_name, prefab: effect_prefab);
        new_obj.transform.SetParent(effects_parent_trans);
        // new_obj.transform.SetParent(effect_prefab.transform.parent);
        new_obj.transform.position = effect_prefab.transform.position;
        new_obj.transform.localScale = effect_prefab.transform.localScale;
        new_obj.transform.rotation = effect_prefab.transform.rotation;
        
        // BdTools.get_word_position()
        // effect_prefab.transform
        new_obj.SetActive(true);
        ObjectPoolManager.instance.recycle_obj(new_obj, 3f);
    }
}
